<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chat with Assistant</title>
</head>
<body>
    <h1>Chat with Assistant</h1>
    <input type="text" id="userInput" placeholder="Type your message here">
    <button id="sendButton">Send</button>
    <div id="response"></div>

    <script>
        document.getElementById('sendButton').onclick = function() {
            const input = document.getElementById('userInput').value;

            fetch('/send_input', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ input: input })
            })
            .then(response => response.json())
            .then(data => {
                if (data.response) {
                    document.getElementById('response').innerText = 'Assistant: ' + data.response;
                } else if (data.error) {
                    document.getElementById('response').innerText = 'Error: ' + data.error;
                }
            })
            .catch(error => console.error('Error:', error));
        };
    </script>
</body>
</html>
